{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "files = os.listdir('../../pythia/results/bias-evals/')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "pythia_files = []\n",
    "intervened_files = []\n",
    "long_intervened_files = []\n",
    "for f in files:\n",
    "  if 'pythia' in f:\n",
    "    pythia_files.append(f)\n",
    "  elif 'intervention' in f:\n",
    "    intervened_files.append(f)\n",
    "  elif 'long-intervention' in f:\n",
    "    long_intervened_files.append(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# for file in pythia_files:\n",
    "#     if 'new' in file:\n",
    "#         name_split = file.split('-')\n",
    "#         print(file)\n",
    "#         for file_without_new_in_name in files:\n",
    "#             sub_name_split = file_without_new_in_name.split('-')\n",
    "#             if name_split[1:5] == sub_name_split[:4]:\n",
    "#                 # Delete the original file\n",
    "#                 os.remove('../../pythia/results/bias-evals/' + file_without_new_in_name)\n",
    "#                 # Rename the sub_file to the original file name\n",
    "#                 os.rename('../../pythia/results/bias-evals/' + file, '../../pythia/results/bias-evals/' + file_without_new_in_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# for file in intervened_files:\n",
    "#     if 'deduped' not in file:\n",
    "#         print(\"old\", file)\n",
    "#         name_split = file.split('-')\n",
    "#         new_name = name_split[:2] + ['deduped'] + name_split[2:]\n",
    "#         new_name = '-'.join(new_name)\n",
    "#         print(\"new\", new_name)\n",
    "#         os.rename('../../pythia/results/bias-evals/' + file, '../../pythia/results/bias-evals/' + new_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# for f in pythia_files:\n",
    "#     if 'deduped' not in f:\n",
    "#         print(\"Old\", f)\n",
    "#         name_split = f.split('-')\n",
    "#         if name_split[0] == 'new':\n",
    "#             new_name = name_split[:3] + ['deduped'] + name_split[3:]\n",
    "#         else:\n",
    "#             new_name = name_split[:2] + ['deduped'] + name_split[2:]\n",
    "#         # print(\"New\", \"-\".join(new_name))\n",
    "#         os.rename('../../pythia/results/bias-evals/' + f, '../../pythia/results/bias-evals/' + \"-\".join(new_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "a5a87ee616be0254e3f1af9223138e3faeac65b2c9d91bc22a9fc5a4a8bd8eb0"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
